package com.learn.temp.rmi;

import java.lang.management.ManagementFactory;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
 * @author wangxing
 * @version 2020/6/7 19:10 Administrator
 */
public class RmiClient {
    public static void main(String[] args) throws RemoteException, NotBoundException, MalformedURLException {
        String name = "rmi://localhost:8080/UserService";
        UserService userService = (UserService) Naming.lookup(name);
        System.out.println(String.format(" 引用成功 :%s ",
                ManagementFactory.getRuntimeMXBean().getName()));
        System.out.println(userService.getName(1));
    }
}
